

<template tag="以下文档内容为hycli自动生成">
  <el-dialog
    v-model="conf.visible"
    
    :title="title"
    :width="conf.width"
    draggable
    align-center="true"
    :close-on-click-modal="false"
  >
<el-form :model="form"  ref="form" :rules="rules_aaaxn">
    <el-row>
    <el-col :span="24">
    <!-- {"index":30,"raw":"title","name":"title","cname":"Title","type":{"raw":"varchar(128)","name":"varchar","len":128,"dlen":0},"defValue":"","allowNull":false,"constraints":["q","c","l","u","v","le","rows(1)","#like","lw(160)"],"desc":{"raw":"标题","name":"标题"}} -->
    <!--标题 输入控件 -->
    <el-form-item prop="title" label="标题" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.title"  maxlength="128" 
      :rows="1"  type="textarea" show-word-limit  placeholder="请输入标题"  />
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":34,"raw":"dev_task","name":"dev_task","cname":"DevTask","type":{"raw":"number(10)","name":"number","len":10,"dlen":0},"defValue":"","allowNull":true,"constraints":["c","u","v","le","rows(1)","sl(dev_task,@related_demand,#lob_id)"],"desc":{"raw":"开发任务","name":"开发任务"}} -->
     <!--开发任务 下拉控件 -->
    <el-form-item prop="dev_task" label="开发任务" label-width="100px" label-position="right">
      <el-select   v-model="form.dev_task" style="width: 100%" filterable clearable
        placeholder="请选择开发任务" >
        <el-option v-for="item in dev_taskList" :key="item.value" :label="item.name" :value="item.value" />
      </el-select>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":35,"raw":"test_task","name":"test_task","cname":"TestTask","type":{"raw":"number(10)","name":"number","len":10,"dlen":0},"defValue":"","allowNull":true,"constraints":["c","u","v","le","rows(1)","sl(test_task,@related_demand,#lob_id)"],"desc":{"raw":"测试任务","name":"测试任务"}} -->
     <!--测试任务 下拉控件 -->
    <el-form-item prop="test_task" label="测试任务" label-width="100px" label-position="right">
      <el-select   v-model="form.test_task" style="width: 100%" filterable clearable
        placeholder="请选择测试任务" >
        <el-option v-for="item in test_taskList" :key="item.value" :label="item.name" :value="item.value" />
      </el-select>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":36,"raw":"bug_level","name":"bug_level","cname":"BugLevel","type":{"raw":"number(1)","name":"number","len":1,"dlen":0},"defValue":"0","allowNull":false,"constraints":["c","l","le","q","u","v","sl","tp(multiselect,q)","tp(radio,c-u)","tp(tag,l)","lw(60)","color"],"desc":{"raw":"等级","name":"等级"}} -->
    <el-form-item prop="bug_level" label="等级" label-width="100px" label-position="right">
      <el-radio-group v-model="form.bug_level"   >
        <el-radio-button v-for="item in bug_levelList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":37,"raw":"bug_type","name":"bug_type","cname":"BugType","type":{"raw":"number(2)","name":"number","len":2,"dlen":0},"defValue":"","allowNull":false,"constraints":["c","l","u","v","le","sl","tp(radio,c-u)","color","lw(60)"],"desc":{"raw":"缺陷分类","name":"缺陷分类"}} -->
    <el-form-item prop="bug_type" label="缺陷分类" label-width="100px" label-position="right">
      <el-radio-group v-model="form.bug_type"   >
        <el-radio-button v-for="item in bug_typeList" :key="item.value" :label="item.value" >
            {{item.name}}
        </el-radio-button>
      </el-radio-group>
    </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":38,"raw":"reproduce_steps","name":"reproduce_steps","cname":"ReproduceSteps","type":{"raw":"text","name":"text","len":0,"dlen":0},"defValue":"","allowNull":false,"constraints":["c","u","v","le","rows(8)","tp(rtext,c-u-le)"],"desc":{"raw":"重现步骤","name":"重现步骤"}} -->
    <!--重现步骤 输入控件 -->
    <el-form-item prop="reproduce_steps" label="重现步骤" label-width="100px" label-position="right">
      <rtext :html="form.reproduce_steps" :rows="8" @onChange="onRtextreproduce_stepsChange"></rtext>
    </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":45,"raw":"os","name":"os","cname":"Os","type":{"raw":"varchar(32)","name":"varchar","len":32,"dlen":0},"defValue":"","allowNull":true,"constraints":["c","u","v","le"],"desc":{"raw":"操作系统","name":"操作系统"}} -->
    <!--操作系统 输入控件 -->
    <el-form-item prop="os" label="操作系统" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.os"  maxlength="32" 
      :rows="0"  placeholder="请输入操作系统"  />
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":46,"raw":"browser","name":"browser","cname":"Browser","type":{"raw":"varchar(32)","name":"varchar","len":32,"dlen":0},"defValue":"","allowNull":true,"constraints":["c","u","v","le"],"desc":{"raw":"浏览器","name":"浏览器"}} -->
    <!--浏览器 输入控件 -->
    <el-form-item prop="browser" label="浏览器" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.browser"  maxlength="32" 
      :rows="0"  placeholder="请输入浏览器"  />
      </el-form-item>
    </el-col>
    </el-row>
</el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="hide" icon="close">取消</el-button>
        <el-button type="primary" @click="save" icon="select">提交</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
import rtext from "@/views/cmpnts/rtext.vue"
export default {
  components: {
    rtext
},
  data() {
    return {
      conf: {
        visible: false,
        width:"70%",
        uploadPath:this.$theia.env.join("/file/upload"),
      },
      title:"修改缺陷管理",
rules_aaaxn:{
    title:[{required:true,message:"请输入标题",trigger: 'blur'}],
    dev_task:[{required:false,message:"请输入开发任务",trigger: 'blur'}],
    test_task:[{required:false,message:"请输入测试任务",trigger: 'blur'}],
    bug_level:[{required:true,message:"请输入等级",trigger: 'blur'}],
    bug_type:[{required:true,message:"请输入缺陷分类",trigger: 'blur'}],
    reproduce_steps:[{required:true,message:"请输入重现步骤",trigger: 'blur'}],
    os:[{required:false,message:"请输入操作系统",trigger: 'blur'}],
    browser:[{required:false,message:"请输入浏览器",trigger: 'blur'}],
  },
    form:{
        title:"",
        dev_task:"",
        test_task:"",
        bug_level:"",
        bug_type:"",
        reproduce_steps:"",
        os:"",
        browser:"",
    },
    dev_taskList:[],
    test_taskList:[],
    bug_levelList:[],
    bug_typeList:[],
    }
  },
  methods: {
    show(form) {
      this.conf.visible = true;
      this.loadEnums_aaaxn()
      this.form = Object.assign(form,this.$route.params)
      this.get(form)
    },
      get(form){
        let that = this
        this.conf.loading = true
        let postForm = {}
        postForm.bug_id = form.bug_id
        this.$theia.http.get("/ws/test/bug",postForm).then(res=>{
          that.form = Object.assign(that.form, res)
        //处理枚举重新绑定
          this.loadEnums_aaaxn()
          that.conf.loading = false
        }).catch(res=>{
          let code = ((res||{}).response||{}).status||0
          let msg = `缺陷管理查询失败(${code})`
          that.$notify.error({title: '失败',message:msg ,duration:5000})
        })
    },
    save(){
        this.$refs.form.validate((v=>{
            if(v) this.onSave()
        }))
    },
    onSave(){
      let that = this
        let postForm = Object.assign({},this.form)
        this.$theia.http.put("/ws/test/bug",postForm).then(res=>{
            that.$notify.success({title: '成功',message: '缺陷管理保存成功',duration:5000})
            that.hide()
            that.$emit("onsaved")
        }).catch(res=>{
            let code = ((res||{}).response||{}).status||0
            let msg = `缺陷管理修改失败(${code})`
            that.$notify.error({title: '失败',message: msg,duration:5000})
        })
    },
    hide() {
      this.conf.visible = false;
      this.$refs.form.resetFields();
    },
    onRtextreproduce_stepsChange(text,urls){
      this.form.reproduce_steps = text
      this.form.reproduce_steps_urls = (urls||[]).join(",")
    },
     onUploadSuccess(response){
    },
    loadEnums_aaaxn(){
        //开发任务
        this.dev_taskList = this.$theia.enum.get("dev_task",((this.form_aaaxn||this.form).related_demand||"")+"",this.$theia.user.get("lob_id"),false,"")
        //测试任务
        this.test_taskList = this.$theia.enum.get("test_task",((this.form_aaaxn||this.form).related_demand||"")+"",this.$theia.user.get("lob_id"),false,"")
        //等级
        this.bug_levelList = this.$theia.enum.get("bug_level","","" ,false,"")
        //缺陷分类
        this.bug_typeList = this.$theia.enum.get("bug_type","","" ,false,"")
    },

  },
};
</script>

<style scoped>
.form_item_info{
  margin-left: 4px;
  color:#999;
}
.form_item_info:hover{
  cursor: pointer;
  font-weight: 500;
  color:#333;
}
</style>